package com.xcw.handler;

import com.xcw.base.dto.UserDto;
import com.xcw.service.UserService;
import com.xcw.util.RedisUtil;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author bhx
 * @Date 2022/8/27 23:58
 * @Description TODO
 */
@Component
public class LoginHandler {
    @Autowired
    RedisUtil redisUtil;

    @Autowired
    UserService userService;

    @Value("${server.domain}")
    String domain;

    public String hanlde(String openid, String context, WxMpService wxMpService) {
        if (context.length() != 6 && redisUtil.hasKey("ticket-" + context)){
            return "登录验证码不正确！";
        }
        UserDto userDto = userService.register(openid);
        return "";
    }
}
